import java.util.ArrayList;
import java.util.List;

/**
 * Created by asus on 2017/9/25.
 */
public class ArrayTest {

         static List<MyArray> mArrayList1 = new ArrayList<>();
         static List<MyArray> mArrayList2 = new ArrayList<>();
         static List<MyArray> NewArrayList = new ArrayList<>();
         public void Setup(){
             setup();
         }

        public static void setup() {
            mArrayList1.add(new MyArray(0));
            mArrayList1.add(new MyArray(1));
            mArrayList1.add(new MyArray(2));
            mArrayList1.add(new MyArray(3));
            mArrayList1.add(new MyArray(3));
            mArrayList1.add(new MyArray(4));


            mArrayList2.add(new MyArray(2));
            mArrayList2.add(new MyArray(3));
            mArrayList2.add(new MyArray(3));
            mArrayList2.add(new MyArray(4));
            mArrayList2.add(new MyArray(4));
            mArrayList2.add(new MyArray(5));

        }


        public static List<? extends Comparable> mergeSortedList(List<? extends Comparable> aList,
                                                                 List<? extends Comparable> bList){
            setup();
            List<Comparable> mlist1 = new ArrayList();

            for (int i =0;i<aList.size();i++){
                mlist1.add(aList.get(i));
            }
            for (int i =0;i<bList.size();i++){
                mlist1.add(bList.get(i));
            }

            selectionSort(mlist1);
            return mlist1;
        }

        public  static void selectionSort(List<Comparable> myList){
            int min;
            for (int index =0;index<myList.size()-1;index++){
                min = index;
                for (int scan = index+1;scan < myList.size();scan++){
                    if (myList.get(scan).compareTo(myList.get(min))<0)
                        min = scan;

                }
                swap(myList,min,index);

            }

        }
        private static void swap(List<Comparable> myList,int index1,int index2){
            List<Comparable> list = new ArrayList();
            list.add(myList.get(index1));
            myList.set(index1,myList.get(index2));
            myList.set(index2,list.get(0));


        }

    public static void main(String[] args) {
        ArrayTest mtest = new ArrayTest();
        List list = mergeSortedList(mArrayList1,mArrayList2);
        int num1 = mArrayList1.size();
        int num2 = mArrayList2.size();
        int num3 = list.size();
        for (int i =0;i<num1;i++){
            System.out.print(mArrayList1.get(i)+" ");
        }
        System.out.println();
        for (int i= 0;i<num2;i++){
            System.out.print(mArrayList2.get(i)+" ");
        }
        System.out.println();
       for (int i =0;i<num3;i++){
           System.out.print(list.get(i)+" ");
       }

    }

}
